#pragma once

	// FBO's are a pixel-buffer aka p-buffer replacement, check out this for example use
	// FBO's dont actually store pixeldata, they store state. Like VBO's dont store vertices.
	// http://www.opengl.org/wiki/GL_EXT_framebuffer_object#Color_only

	/* you can attach various types of data to a FBO, like
		-color 
		-depth
	*/
#include <gl/glew.h>
#include <gl/glfw.h>

class FBO
{
	private:
	unsigned int fboId; // framebuffer obj handle.

	bool hasFBOError();
	
	public:
	FBO();
	~FBO();
	unsigned int getId(){ return fboId; }
	unsigned int color_rb;
	unsigned int depth_rb;
	unsigned int shadowMap; // should not be here?!

	void init(int width=512, int height=512);
	void initShadowFBO(int shadowMapWidth=512, int shadowMapHeight=512);
	void begin() { glBindFramebuffer(GL_FRAMEBUFFER, fboId); }
	void end() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }
};


